d-pac.docs

comparative-selection

NPM version Build Status Dependency Status

Comparative selection algorithm plugin for d-pac platform

See d-pac.plugin specifications for more information

Based on NoMoreMarking's cj module.

Description

The algorithm accepts a queue (Array) of items, then:

  1. pseudo-randomizes the queue order
  2. sorts the queue by compared.length
  3. retains the first item as 'selected'
  4. retains the next valid item as 'opponent':
    • either, the next item in the (shuffled) queue when 'selected' has no previous comparisons.
    • or, the next item in the (shuffled) queue 'selected' hasn't been compared to yet.
  5. returns both items as an Array

Install

$ npm install --save comparative-selection

Usage

var cs = require('comparative-selection');

cs.select( representations );

API

select(items)

  • items: {Object[]} (required) Array of items with following minimal structure:

    • _id : {String} (required) Unique identifier for the item
    • compared : {String[]} (required) Array of unique identifiers

License

GPL v3 © d-pac